// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 

package net.minecraft;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.imageio.ImageIO;

// Referenced classes of package net.minecraft:
//            LoginForm, MinecraftUtil, Launcher

public class LauncherFrame extends Frame
{

    public static final int VERSION = 12;
    private static final long serialVersionUID = 1L;
    private Launcher launcher;
    public LoginForm loginForm;
    public SettingsPanel settingspanel;
    public boolean forceUpdate;
    public BackupPanel backuppanel;

    public LauncherFrame()
    {
        super("Minecraft Launcher (by AnjoCaido and djmati11)");
        MinecraftUtil.readSettings();
        forceUpdate = false;
        System.out.println("Hello!");
        setBackground(Color.BLACK);

        
     
        
        backuppanel = new BackupPanel(this);
        setLayout(new BorderLayout());
        add(backuppanel, "Center");
        backuppanel.setPreferredSize(new Dimension(854, 480));
        settingspanel = new SettingsPanel(this);
        setLayout(new BorderLayout());
        add(settingspanel, "Center");
        settingspanel.setPreferredSize(new Dimension(854, 480));
        removeAll();
        loginForm = new LoginForm(this);
        add(loginForm, "Center");
        loginForm.setPreferredSize(new Dimension(854, 480));
        pack();
        setLocationRelativeTo(null);
        try
        {
            setIconImage(ImageIO.read((net.minecraft.LauncherFrame.class).getResource("favicon.png")));
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
        addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent windowevent)
            {
                (new Thread() {

                    public void run()
                    {
                        try
                        {
                            Thread.sleep(30000L);
                        }
                        catch(InterruptedException interruptedexception)
                        {
                            interruptedexception.printStackTrace();
                        }
                        System.out.println("FORCING EXIT!");
                        System.exit(0);
                    }

                }
).start();
                if(launcher != null)
                {
                    launcher.stop();
                    launcher.destroy();
                }
                System.exit(0);
            }

        }
);
    }

    public String getFakeResult(String s)
    {
        return (new StringBuilder()).append(MinecraftUtil.getFakeLatestVersion()).append(":35b9fd01865fda9d70b157e244cf801c:").append(s).append(":12345:").toString();
    }

    public void login(String s)
    {
        String s1 = getFakeResult(s);
        String as[] = s1.split(":");
        launcher = new Launcher();
        launcher.forceUpdate = forceUpdate;
        launcher.customParameters.put("userName", as[2].trim());
        launcher.customParameters.put("sessionId", as[3].trim());
        launcher.init();
        removeAll();
        add(launcher, "Center");
        validate();
        launcher.start();
        loginForm.loginOk();
        loginForm = null;
        setTitle("Minecraft");
    }

    /*private void showError(String s)
    {
        removeAll();
        add(loginForm);
        loginForm.setError(s);
        validate();
    }*/

    public boolean canPlayOffline(String s)
    {
        Launcher launcher1 = new Launcher();
        launcher1.init(s, "12345");
        return launcher1.canPlayOffline();
    }
    
    public void showSettings()
    {
    	
    	removeAll();
        setLayout(new BorderLayout());

        add(settingspanel);
        settingspanel.readSettings();
        validate();
    }
    
    public void showLogin()
    {
    	
    	removeAll();
        setLayout(new BorderLayout());

        add(loginForm);
        validate();
    }
    public void showBackup()
    {
    	
    	removeAll();
        setLayout(new BorderLayout());

        add(backuppanel);
        validate();
    }
    
    public static void main(String args[])
    {
        LauncherFrame launcherframe = new LauncherFrame();
        launcherframe.setVisible(true);
    }

}
